<template>
	<view class="news_item">
		<view class="header">
			<view class="header-icon">
				<image src="../../static/icon/back.png" style="width: 40rpx;height: 40rpx;" @click="back"></image>
			</view>
			<view class="newsTitle">
				{{service_info.name}}
			</view>
		</view>
		<!-- <view style="height: 100%;
			padding: 220rpx 20rpx 0;">
			<image :src="service_info.imgUrl" style="width: 100%;margin-bottom: 20rpx;"></image>
		</view> -->
		<view class="imgContent">
			<view class="tit" v-html="service_info.serviceContent"  />
		</view>
		<!-- 回到顶部 -->
		<view class="wrap">
			<u-back-top :scroll-top="scrollTop"></u-back-top>
		</view>
	</view>
</template>

<script>
	import until from '@/main.js'
	export default {
		data() {
			return {
				id: 0,
				title: '',
				serviceList: [],
				// 回到顶部样式
				scrollTop: 0,
				mode: "square",
				iconStyle: {
					fontSize: "32rpx",
					color: "#2979ff",
				},
				dataList: [],
				service_info: {}

			}
		},
		onLoad(options) {
			this.id = options.id
			this.getDetailList()
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods: {
			//获取文章详情
			getDetailList() {
				const that = this
				that.$api.request('serve', 'detail', {
					serverId: this.id
				}).then(res => {
					that.service_info = res.data
					if (that.service_info.serviceContent) {
						that.service_info.serviceContent = until.formatRichText(that.service_info.serviceContent)
						// that.service_info.serviceContent = that.service_info.serviceContent.replace(/\<img/gi, '<img style="max-width:100%;height:auto;"');
					}
				})
			},
			// 返回
			back() {
				const pages = getCurrentPages()
				if (pages && pages.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					history.go(-1)
				}
			}
		}
	}
</script>

<style lang="scss">
	.header {
		width: 100%;
		display: flex;
		padding: 50px 0 10px 0;
		position: fixed;
		background-color: #fff;

		.header-icon {
			padding: 20rpx;
		}

		.newsTitle {
			padding-top: 18rpx;
			font-size: 35rpx;
			font-weight: bolder;
			display: flex;
			justify-content: center;
			flex-wrap: wrap;
			width: 80%;
		}
	}

	.title {
		font-size: 38rpx;
		font-weight: 500;
		letter-spacing: 0.5rem;
		border-left: 4rpx solid orangered;
		padding-left: 30rpx;
	}

	.imgContent {
		padding: 220rpx 30rpx 10rpx;
		.tit {
			line-height: 1.7;
			margin-bottom: 20rpx;
			color: #666;
		}
		.img{
			max-width: 100%;
		}

	}

	.news_item {

		.info {
			font-size: 25rpx;
			justify-content: space-between;
			display: flex;
			padding: 30rpx;
			color: #999999;

			text:nth-child(2) {
				margin-left: 30rpx;
			}
		}
	}
</style>
